{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Importing PulP solver\n",
    "from pulp import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Demand points\n",
    "demand_points=['Mina Salman','Port of Haifa']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mina Salman', 'Port of Haifa']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "demand_points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Supply Points\n",
    "supply_points=['Port of Santos','Sihanoukville','Douala','Port of Shanghai','Puerto Quetzal','Port of Jawaharlal Nehru','Port of Tanjung Priok','Port of Abidjan','Port of Monrovia','Penang Port','Port of Manzanillo','Port of Yangon','Port of Lagos','Port of Manila','Port of  Colombo','Port of Bangkok','Port of Saigon']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Port of Santos',\n",
       " 'Sihanoukville',\n",
       " 'Douala',\n",
       " 'Port of Shanghai',\n",
       " 'Puerto Quetzal',\n",
       " 'Port of Jawaharlal Nehru',\n",
       " 'Port of Tanjung Priok',\n",
       " 'Port of Abidjan',\n",
       " 'Port of Monrovia',\n",
       " 'Penang Port',\n",
       " 'Port of Manzanillo',\n",
       " 'Port of Yangon',\n",
       " 'Port of Lagos',\n",
       " 'Port of Manila',\n",
       " 'Port of  Colombo',\n",
       " 'Port of Bangkok',\n",
       " 'Port of Saigon']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "supply_points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the distances\n",
    "distance = dict(zip(supply_points,[dict(zip(demand_points, [9662,7667])),\n",
    "dict(zip(demand_points, [4867,6321])),\n",
    "dict(zip(demand_points, [8271,6011])),\n",
    "dict(zip(demand_points, [6882,8336])),\n",
    "dict(zip(demand_points, [12209,8820])),\n",
    "dict(zip(demand_points, [1589,3510])),\n",
    "dict(zip(demand_points, [4660,6000])),\n",
    "dict(zip(demand_points, [8823,5211])),\n",
    "dict(zip(demand_points, [8206,4816])),\n",
    "dict(zip(demand_points, [3856,5310])),\n",
    "dict(zip(demand_points, [13061,9673])),\n",
    "dict(zip(demand_points, [3942,5434])),\n",
    "dict(zip(demand_points, [8570,5662])),\n",
    "dict(zip(demand_points, [5794,7248])),\n",
    "dict(zip(demand_points, [2531,4010])),\n",
    "dict(zip(demand_points, [5102,6556])),\n",
    "dict(zip(demand_points, [4964,6418]))]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Santos': {'Mina Salman': 9662, 'Port of Haifa': 7667},\n",
       " 'Sihanoukville': {'Mina Salman': 4867, 'Port of Haifa': 6321},\n",
       " 'Douala': {'Mina Salman': 8271, 'Port of Haifa': 6011},\n",
       " 'Port of Shanghai': {'Mina Salman': 6882, 'Port of Haifa': 8336},\n",
       " 'Puerto Quetzal': {'Mina Salman': 12209, 'Port of Haifa': 8820},\n",
       " 'Port of Jawaharlal Nehru': {'Mina Salman': 1589, 'Port of Haifa': 3510},\n",
       " 'Port of Tanjung Priok': {'Mina Salman': 4660, 'Port of Haifa': 6000},\n",
       " 'Port of Abidjan': {'Mina Salman': 8823, 'Port of Haifa': 5211},\n",
       " 'Port of Monrovia': {'Mina Salman': 8206, 'Port of Haifa': 4816},\n",
       " 'Penang Port': {'Mina Salman': 3856, 'Port of Haifa': 5310},\n",
       " 'Port of Manzanillo': {'Mina Salman': 13061, 'Port of Haifa': 9673},\n",
       " 'Port of Yangon': {'Mina Salman': 3942, 'Port of Haifa': 5434},\n",
       " 'Port of Lagos': {'Mina Salman': 8570, 'Port of Haifa': 5662},\n",
       " 'Port of Manila': {'Mina Salman': 5794, 'Port of Haifa': 7248},\n",
       " 'Port of  Colombo': {'Mina Salman': 2531, 'Port of Haifa': 4010},\n",
       " 'Port of Bangkok': {'Mina Salman': 5102, 'Port of Haifa': 6556},\n",
       " 'Port of Saigon': {'Mina Salman': 4964, 'Port of Haifa': 6418}}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Rubber Demand\n",
    "rubber_demand=dict(zip(demand_points, [82512716.94,71757741.82]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Mina Salman': 82512716.94, 'Port of Haifa': 71757741.82}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rubber_demand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Rubber Supply\n",
    "rubber_supply=dict(zip(supply_points, [1258648.2900,8234049.7510,217343.9060,8784079.7960,3935392.5450,6522791.1570,34239646.0300,3411326.1430,603911.1280,5312726.1900,330881.7674,1946363.3380,1386711.0420,2541650.1950,741564.4317,49185954.9800,25617418.0800])) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Santos': 1258648.29,\n",
       " 'Sihanoukville': 8234049.751,\n",
       " 'Douala': 217343.906,\n",
       " 'Port of Shanghai': 8784079.796,\n",
       " 'Puerto Quetzal': 3935392.545,\n",
       " 'Port of Jawaharlal Nehru': 6522791.157,\n",
       " 'Port of Tanjung Priok': 34239646.03,\n",
       " 'Port of Abidjan': 3411326.143,\n",
       " 'Port of Monrovia': 603911.128,\n",
       " 'Penang Port': 5312726.19,\n",
       " 'Port of Manzanillo': 330881.7674,\n",
       " 'Port of Yangon': 1946363.338,\n",
       " 'Port of Lagos': 1386711.042,\n",
       " 'Port of Manila': 2541650.195,\n",
       " 'Port of  Colombo': 741564.4317,\n",
       " 'Port of Bangkok': 49185954.98,\n",
       " 'Port of Saigon': 25617418.08}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rubber_supply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set Problem Variables\n",
    "prob = LpProblem(\"Transportation\", LpMinimize)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "None\n",
       "VARIABLES"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set Problem Variables\n",
    "routes = [(i,j) for i in supply_points for j in demand_points]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('Port of Santos', 'Mina Salman'),\n",
       " ('Port of Santos', 'Port of Haifa'),\n",
       " ('Sihanoukville', 'Mina Salman'),\n",
       " ('Sihanoukville', 'Port of Haifa'),\n",
       " ('Douala', 'Mina Salman'),\n",
       " ('Douala', 'Port of Haifa'),\n",
       " ('Port of Shanghai', 'Mina Salman'),\n",
       " ('Port of Shanghai', 'Port of Haifa'),\n",
       " ('Puerto Quetzal', 'Mina Salman'),\n",
       " ('Puerto Quetzal', 'Port of Haifa'),\n",
       " ('Port of Jawaharlal Nehru', 'Mina Salman'),\n",
       " ('Port of Jawaharlal Nehru', 'Port of Haifa'),\n",
       " ('Port of Tanjung Priok', 'Mina Salman'),\n",
       " ('Port of Tanjung Priok', 'Port of Haifa'),\n",
       " ('Port of Abidjan', 'Mina Salman'),\n",
       " ('Port of Abidjan', 'Port of Haifa'),\n",
       " ('Port of Monrovia', 'Mina Salman'),\n",
       " ('Port of Monrovia', 'Port of Haifa'),\n",
       " ('Penang Port', 'Mina Salman'),\n",
       " ('Penang Port', 'Port of Haifa'),\n",
       " ('Port of Manzanillo', 'Mina Salman'),\n",
       " ('Port of Manzanillo', 'Port of Haifa'),\n",
       " ('Port of Yangon', 'Mina Salman'),\n",
       " ('Port of Yangon', 'Port of Haifa'),\n",
       " ('Port of Lagos', 'Mina Salman'),\n",
       " ('Port of Lagos', 'Port of Haifa'),\n",
       " ('Port of Manila', 'Mina Salman'),\n",
       " ('Port of Manila', 'Port of Haifa'),\n",
       " ('Port of  Colombo', 'Mina Salman'),\n",
       " ('Port of  Colombo', 'Port of Haifa'),\n",
       " ('Port of Bangkok', 'Mina Salman'),\n",
       " ('Port of Bangkok', 'Port of Haifa'),\n",
       " ('Port of Saigon', 'Mina Salman'),\n",
       " ('Port of Saigon', 'Port of Haifa')]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "routes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Decision Variables\n",
    "X = LpVariable.dicts(\"ShipmentAmount\",(supply_points, demand_points),0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Santos': {'Mina Salman': ShipmentAmount_Port_of_Santos_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Santos_Port_of_Haifa},\n",
       " 'Sihanoukville': {'Mina Salman': ShipmentAmount_Sihanoukville_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Sihanoukville_Port_of_Haifa},\n",
       " 'Douala': {'Mina Salman': ShipmentAmount_Douala_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Douala_Port_of_Haifa},\n",
       " 'Port of Shanghai': {'Mina Salman': ShipmentAmount_Port_of_Shanghai_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Shanghai_Port_of_Haifa},\n",
       " 'Puerto Quetzal': {'Mina Salman': ShipmentAmount_Puerto_Quetzal_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Puerto_Quetzal_Port_of_Haifa},\n",
       " 'Port of Jawaharlal Nehru': {'Mina Salman': ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa},\n",
       " 'Port of Tanjung Priok': {'Mina Salman': ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa},\n",
       " 'Port of Abidjan': {'Mina Salman': ShipmentAmount_Port_of_Abidjan_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Abidjan_Port_of_Haifa},\n",
       " 'Port of Monrovia': {'Mina Salman': ShipmentAmount_Port_of_Monrovia_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Monrovia_Port_of_Haifa},\n",
       " 'Penang Port': {'Mina Salman': ShipmentAmount_Penang_Port_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Penang_Port_Port_of_Haifa},\n",
       " 'Port of Manzanillo': {'Mina Salman': ShipmentAmount_Port_of_Manzanillo_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa},\n",
       " 'Port of Yangon': {'Mina Salman': ShipmentAmount_Port_of_Yangon_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Yangon_Port_of_Haifa},\n",
       " 'Port of Lagos': {'Mina Salman': ShipmentAmount_Port_of_Lagos_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Lagos_Port_of_Haifa},\n",
       " 'Port of Manila': {'Mina Salman': ShipmentAmount_Port_of_Manila_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Manila_Port_of_Haifa},\n",
       " 'Port of  Colombo': {'Mina Salman': ShipmentAmount_Port_of__Colombo_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of__Colombo_Port_of_Haifa},\n",
       " 'Port of Bangkok': {'Mina Salman': ShipmentAmount_Port_of_Bangkok_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Bangkok_Port_of_Haifa},\n",
       " 'Port of Saigon': {'Mina Salman': ShipmentAmount_Port_of_Saigon_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Saigon_Port_of_Haifa}}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Objective Function\n",
    "prob += sum(X[i][j]*distance[i][j] for (i,j) in routes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "8271*ShipmentAmount_Douala_Mina_Salman + 6011*ShipmentAmount_Douala_Port_of_Haifa + 3856*ShipmentAmount_Penang_Port_Mina_Salman + 5310*ShipmentAmount_Penang_Port_Port_of_Haifa + 8823*ShipmentAmount_Port_of_Abidjan_Mina_Salman + 5211*ShipmentAmount_Port_of_Abidjan_Port_of_Haifa + 5102*ShipmentAmount_Port_of_Bangkok_Mina_Salman + 6556*ShipmentAmount_Port_of_Bangkok_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 8570*ShipmentAmount_Port_of_Lagos_Mina_Salman + 5662*ShipmentAmount_Port_of_Lagos_Port_of_Haifa + 5794*ShipmentAmount_Port_of_Manila_Mina_Salman + 7248*ShipmentAmount_Port_of_Manila_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 8206*ShipmentAmount_Port_of_Monrovia_Mina_Salman + 4816*ShipmentAmount_Port_of_Monrovia_Port_of_Haifa + 4964*ShipmentAmount_Port_of_Saigon_Mina_Salman + 6418*ShipmentAmount_Port_of_Saigon_Port_of_Haifa + 9662*ShipmentAmount_Port_of_Santos_Mina_Salman + 7667*ShipmentAmount_Port_of_Santos_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 4660*ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman + 6000*ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa + 3942*ShipmentAmount_Port_of_Yangon_Mina_Salman + 5434*ShipmentAmount_Port_of_Yangon_Port_of_Haifa + 2531*ShipmentAmount_Port_of__Colombo_Mina_Salman + 4010*ShipmentAmount_Port_of__Colombo_Port_of_Haifa + 12209*ShipmentAmount_Puerto_Quetzal_Mina_Salman + 8820*ShipmentAmount_Puerto_Quetzal_Port_of_Haifa + 4867*ShipmentAmount_Sihanoukville_Mina_Salman + 6321*ShipmentAmount_Sihanoukville_Port_of_Haifa + 0\n",
       "VARIABLES\n",
       "ShipmentAmount_Douala_Mina_Salman Continuous\n",
       "ShipmentAmount_Douala_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Penang_Port_Mina_Salman Continuous\n",
       "ShipmentAmount_Penang_Port_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manila_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manila_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Santos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Santos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Mina_Salman Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Sihanoukville_Mina_Salman Continuous\n",
       "ShipmentAmount_Sihanoukville_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "8271*ShipmentAmount_Douala_Mina_Salman + 6011*ShipmentAmount_Douala_Port_of_Haifa + 3856*ShipmentAmount_Penang_Port_Mina_Salman + 5310*ShipmentAmount_Penang_Port_Port_of_Haifa + 8823*ShipmentAmount_Port_of_Abidjan_Mina_Salman + 5211*ShipmentAmount_Port_of_Abidjan_Port_of_Haifa + 5102*ShipmentAmount_Port_of_Bangkok_Mina_Salman + 6556*ShipmentAmount_Port_of_Bangkok_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 8570*ShipmentAmount_Port_of_Lagos_Mina_Salman + 5662*ShipmentAmount_Port_of_Lagos_Port_of_Haifa + 5794*ShipmentAmount_Port_of_Manila_Mina_Salman + 7248*ShipmentAmount_Port_of_Manila_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 8206*ShipmentAmount_Port_of_Monrovia_Mina_Salman + 4816*ShipmentAmount_Port_of_Monrovia_Port_of_Haifa + 4964*ShipmentAmount_Port_of_Saigon_Mina_Salman + 6418*ShipmentAmount_Port_of_Saigon_Port_of_Haifa + 9662*ShipmentAmount_Port_of_Santos_Mina_Salman + 7667*ShipmentAmount_Port_of_Santos_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 4660*ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman + 6000*ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa + 3942*ShipmentAmount_Port_of_Yangon_Mina_Salman + 5434*ShipmentAmount_Port_of_Yangon_Port_of_Haifa + 2531*ShipmentAmount_Port_of__Colombo_Mina_Salman + 4010*ShipmentAmount_Port_of__Colombo_Port_of_Haifa + 12209*ShipmentAmount_Puerto_Quetzal_Mina_Salman + 8820*ShipmentAmount_Puerto_Quetzal_Port_of_Haifa + 4867*ShipmentAmount_Sihanoukville_Mina_Salman + 6321*ShipmentAmount_Sihanoukville_Port_of_Haifa + 0\n",
       "SUBJECT TO\n",
       "_C1: ShipmentAmount_Douala_Mina_Salman\n",
       " + ShipmentAmount_Penang_Port_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Abidjan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Bangkok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Lagos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manila_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Monrovia_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Saigon_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Santos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Yangon_Mina_Salman\n",
       " + ShipmentAmount_Port_of__Colombo_Mina_Salman\n",
       " + ShipmentAmount_Puerto_Quetzal_Mina_Salman\n",
       " + ShipmentAmount_Sihanoukville_Mina_Salman >= 82512716.94\n",
       "\n",
       "_C2: ShipmentAmount_Douala_Port_of_Haifa\n",
       " + ShipmentAmount_Penang_Port_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Abidjan_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Bangkok_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Lagos_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manila_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Monrovia_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Saigon_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Santos_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Yangon_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of__Colombo_Port_of_Haifa\n",
       " + ShipmentAmount_Puerto_Quetzal_Port_of_Haifa\n",
       " + ShipmentAmount_Sihanoukville_Port_of_Haifa >= 71757741.82\n",
       "\n",
       "VARIABLES\n",
       "ShipmentAmount_Douala_Mina_Salman Continuous\n",
       "ShipmentAmount_Douala_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Penang_Port_Mina_Salman Continuous\n",
       "ShipmentAmount_Penang_Port_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manila_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manila_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Santos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Santos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Mina_Salman Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Sihanoukville_Mina_Salman Continuous\n",
       "ShipmentAmount_Sihanoukville_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Constraints\n",
    "for j in demand_points:\n",
    "    prob += sum(X[i][j] for i in supply_points) >= rubber_demand[j]\n",
    "    \n",
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "8271*ShipmentAmount_Douala_Mina_Salman + 6011*ShipmentAmount_Douala_Port_of_Haifa + 3856*ShipmentAmount_Penang_Port_Mina_Salman + 5310*ShipmentAmount_Penang_Port_Port_of_Haifa + 8823*ShipmentAmount_Port_of_Abidjan_Mina_Salman + 5211*ShipmentAmount_Port_of_Abidjan_Port_of_Haifa + 5102*ShipmentAmount_Port_of_Bangkok_Mina_Salman + 6556*ShipmentAmount_Port_of_Bangkok_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 8570*ShipmentAmount_Port_of_Lagos_Mina_Salman + 5662*ShipmentAmount_Port_of_Lagos_Port_of_Haifa + 5794*ShipmentAmount_Port_of_Manila_Mina_Salman + 7248*ShipmentAmount_Port_of_Manila_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 8206*ShipmentAmount_Port_of_Monrovia_Mina_Salman + 4816*ShipmentAmount_Port_of_Monrovia_Port_of_Haifa + 4964*ShipmentAmount_Port_of_Saigon_Mina_Salman + 6418*ShipmentAmount_Port_of_Saigon_Port_of_Haifa + 9662*ShipmentAmount_Port_of_Santos_Mina_Salman + 7667*ShipmentAmount_Port_of_Santos_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 4660*ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman + 6000*ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa + 3942*ShipmentAmount_Port_of_Yangon_Mina_Salman + 5434*ShipmentAmount_Port_of_Yangon_Port_of_Haifa + 2531*ShipmentAmount_Port_of__Colombo_Mina_Salman + 4010*ShipmentAmount_Port_of__Colombo_Port_of_Haifa + 12209*ShipmentAmount_Puerto_Quetzal_Mina_Salman + 8820*ShipmentAmount_Puerto_Quetzal_Port_of_Haifa + 4867*ShipmentAmount_Sihanoukville_Mina_Salman + 6321*ShipmentAmount_Sihanoukville_Port_of_Haifa + 0\n",
       "SUBJECT TO\n",
       "_C1: ShipmentAmount_Douala_Mina_Salman\n",
       " + ShipmentAmount_Penang_Port_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Abidjan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Bangkok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Lagos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manila_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Monrovia_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Saigon_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Santos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Yangon_Mina_Salman\n",
       " + ShipmentAmount_Port_of__Colombo_Mina_Salman\n",
       " + ShipmentAmount_Puerto_Quetzal_Mina_Salman\n",
       " + ShipmentAmount_Sihanoukville_Mina_Salman >= 82512716.94\n",
       "\n",
       "_C2: ShipmentAmount_Douala_Port_of_Haifa\n",
       " + ShipmentAmount_Penang_Port_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Abidjan_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Bangkok_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Lagos_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manila_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Monrovia_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Saigon_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Santos_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Yangon_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of__Colombo_Port_of_Haifa\n",
       " + ShipmentAmount_Puerto_Quetzal_Port_of_Haifa\n",
       " + ShipmentAmount_Sihanoukville_Port_of_Haifa >= 71757741.82\n",
       "\n",
       "_C3: ShipmentAmount_Port_of_Santos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Santos_Port_of_Haifa = 1258648.29\n",
       "\n",
       "_C4: ShipmentAmount_Sihanoukville_Mina_Salman\n",
       " + ShipmentAmount_Sihanoukville_Port_of_Haifa = 8234049.751\n",
       "\n",
       "_C5: ShipmentAmount_Douala_Mina_Salman + ShipmentAmount_Douala_Port_of_Haifa\n",
       " = 217343.906\n",
       "\n",
       "_C6: ShipmentAmount_Port_of_Shanghai_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa = 8784079.796\n",
       "\n",
       "_C7: ShipmentAmount_Puerto_Quetzal_Mina_Salman\n",
       " + ShipmentAmount_Puerto_Quetzal_Port_of_Haifa = 3935392.545\n",
       "\n",
       "_C8: ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa = 6522791.157\n",
       "\n",
       "_C9: ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa = 34239646.03\n",
       "\n",
       "_C10: ShipmentAmount_Port_of_Abidjan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Abidjan_Port_of_Haifa = 3411326.143\n",
       "\n",
       "_C11: ShipmentAmount_Port_of_Monrovia_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Monrovia_Port_of_Haifa = 603911.128\n",
       "\n",
       "_C12: ShipmentAmount_Penang_Port_Mina_Salman\n",
       " + ShipmentAmount_Penang_Port_Port_of_Haifa = 5312726.19\n",
       "\n",
       "_C13: ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa = 330881.7674\n",
       "\n",
       "_C14: ShipmentAmount_Port_of_Yangon_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Yangon_Port_of_Haifa = 1946363.338\n",
       "\n",
       "_C15: ShipmentAmount_Port_of_Lagos_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Lagos_Port_of_Haifa = 1386711.042\n",
       "\n",
       "_C16: ShipmentAmount_Port_of_Manila_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manila_Port_of_Haifa = 2541650.195\n",
       "\n",
       "_C17: ShipmentAmount_Port_of__Colombo_Mina_Salman\n",
       " + ShipmentAmount_Port_of__Colombo_Port_of_Haifa = 741564.4317\n",
       "\n",
       "_C18: ShipmentAmount_Port_of_Bangkok_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Bangkok_Port_of_Haifa = 49185954.98\n",
       "\n",
       "_C19: ShipmentAmount_Port_of_Saigon_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Saigon_Port_of_Haifa = 25617418.08\n",
       "\n",
       "VARIABLES\n",
       "ShipmentAmount_Douala_Mina_Salman Continuous\n",
       "ShipmentAmount_Douala_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Penang_Port_Mina_Salman Continuous\n",
       "ShipmentAmount_Penang_Port_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Abidjan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Bangkok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Lagos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manila_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manila_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Monrovia_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Saigon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Santos_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Santos_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Yangon_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of__Colombo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Mina_Salman Continuous\n",
       "ShipmentAmount_Puerto_Quetzal_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Sihanoukville_Mina_Salman Continuous\n",
       "ShipmentAmount_Sihanoukville_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Constraints\n",
    "for i in supply_points:\n",
    "    prob += sum(X[i][j] for j in demand_points) == rubber_supply[i]\n",
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Status: Optimal\n",
      "ShipmentAmount_Douala_Port_of_Haifa = 217343.91\n",
      "ShipmentAmount_Penang_Port_Port_of_Haifa = 5312726.2\n",
      "ShipmentAmount_Port_of_Abidjan_Port_of_Haifa = 3411326.1\n",
      "ShipmentAmount_Port_of_Bangkok_Mina_Salman = 28124800.0\n",
      "ShipmentAmount_Port_of_Bangkok_Port_of_Haifa = 21061155.0\n",
      "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman = 6522791.2\n",
      "ShipmentAmount_Port_of_Lagos_Port_of_Haifa = 1386711.0\n",
      "ShipmentAmount_Port_of_Manila_Mina_Salman = 2541650.2\n",
      "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa = 330881.77\n",
      "ShipmentAmount_Port_of_Monrovia_Port_of_Haifa = 603911.13\n",
      "ShipmentAmount_Port_of_Saigon_Mina_Salman = 25617418.0\n",
      "ShipmentAmount_Port_of_Santos_Port_of_Haifa = 1258648.3\n",
      "ShipmentAmount_Port_of_Shanghai_Mina_Salman = 8784079.8\n",
      "ShipmentAmount_Port_of_Tanjung_Priok_Port_of_Haifa = 34239646.0\n",
      "ShipmentAmount_Port_of_Yangon_Mina_Salman = 1946363.3\n",
      "ShipmentAmount_Port_of__Colombo_Mina_Salman = 741564.43\n",
      "ShipmentAmount_Puerto_Quetzal_Port_of_Haifa = 3935392.5\n",
      "ShipmentAmount_Sihanoukville_Mina_Salman = 8234049.8\n",
      "Total kilogram_miles = 854954340552.23\n"
     ]
    }
   ],
   "source": [
    "prob.solve()\n",
    "\n",
    "print(\"Status:\", LpStatus[prob.status])\n",
    "\n",
    "for v in prob.variables():\n",
    "    if v.varValue > 0:\n",
    "        print(v.name, \"=\", v.varValue)\n",
    "\n",
    "print(\"Total kilogram_miles =\", value(prob.objective))\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
